<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>报名人管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			//$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		function checkPassword()
		{
			var password = $("#password").val();
			var passwordCfm = $("#passwordCfm").val();
			
			if(password == passwordCfm)
			{
				$("#passwordCfmTip").hide();
			}
			
		}
		
		function doSubmit()
		{
			
			var userId = "${emsUser.id}";
			
			var password = $("#password").val();
			var passwordCfm = $("#passwordCfm").val();
			
			if(!password || !passwordCfm)
			{
				return true;
			}
			
			var result = false;
			
			// 新增时，判断密码
			if(password.length < 6)
			{
				$("#passwordTip").html("密码长度不符合要求");
		    	$("#passwordTip").show();
		    	return false;
			}
			else
			{
				$("#passwordTip").hide();
				result = true;
			}
			
			if(password != passwordCfm)
			{
				$("#passwordCfmTip").html("输入的密码和确认密码不一致");
		    	$("#passwordCfmTip").show();
		    	return false;
			}
			else
			{
				$("#passwordCfmTip").hide();
				result = true;
			}
			
			
			return result;
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/ems/emsUser/">报名人列表</a></li>
		<li class="active"><a href="${ctx}/ems/emsUser/changePwd?id=${emsUser.id}"><shiro:hasPermission name="ems:emsUser:edit">密码修改</shiro:hasPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="emsUser" action="${ctx}/ems/emsUser/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">登录名：</label>
			<div class="controls">
				<form:input path="loginName" id="loginName" htmlEscape="false" readonly="true" maxlength="64" class="input-xlarge required"/>
				<label id="loginNameTip" class='error' style="display: none;"></label>
				<!-- <span class="help-inline"><font color="red">*</font> </span>
				<span class="help-inline"><font>全站唯一 (字母开头，可包含数字或"_")</font> </span> -->
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">姓名：</label>
			<div class="controls">
				<form:input path="name" id="name" htmlEscape="false" readonly="true" maxlength="64" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">密码：</label>
			<div class="controls">
				<form:password path="password" id="password" htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				<label id="passwordTip" class='error' style="display: none;"></label>
				<span class="help-inline"><font color="red">*</font> </span>
				<span class="help-inline"><font>密码长度至少6位</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">密码确认：</label>
			<div class="controls">
				<form:password path="passwordCfm" id="passwordCfm" onchange="checkPassword();" htmlEscape="false" maxlength="64" class="input-xlarge required"/>
				<label id="passwordCfmTip" class='error' style="display: none;"></label>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="ems:emsUser:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" onclick="return doSubmit();" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>